pkgname=firmware-xiaomi-raphael
pkgver=20240929
pkgrel=0
pkgdesc="Firmware for Xiaomi Mi 9T Pro / Redmi K20 Pro"
arch="aarch64"
_carch="arm64"
subpackages="
	$pkgname-adreno
	$pkgname-adsp
	$pkgname-camera
	$pkgname-cdsp
	$pkgname-ipa
	$pkgname-modem
	$pkgname-slpi
	$pkgname-touchscreen
	$pkgname-venus
	$pkgname-wlan
	"

url="https://github.com/dabao1955/pmos_firmware_xiaomi_raphael"
license="proprietary"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
_commit="89149ad98c7c8443946a518e9fb2ff2e2c83d54d"
source="
	https://github.com/dabao1955/pmos_firmware_xiaomi_raphael/archive/$_commit.tar.gz
	30-gpu-firmware.files"
builddir="$srcdir/pmos_firmware_xiaomi_raphael-$_commit"

package() {
	# parent package is empty
	mkdir -p "$pkgdir"
	install -Dm644 "$srcdir/30-gpu-firmware.files" \
		"$pkgdir/usr/share/mkinitfs/files/30-gpu-firmware.files"
}

# Xiaomi raphael boots with secure boot, it can only load signed firmwares.
adreno() {
	pkgdesc="Xiaomi raphael adreno firmware"
	depends="firmware-qcom-adreno-a650"
	install -Dm644 "$builddir"/sm8150/raphael/a6* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

adsp() {
	pkgdesc="Xiaomi raphael adsp firmware"

	install -Dm644 "$builddir"/sm8150/raphael/adsp* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

camera() {
	pkgdesc="Xiaomi raphael camera firmware"

	install -Dm644 "$builddir"/sm8150/raphael/CAMERA_ICP.elf -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

cdsp() {
	pkgdesc="Xiaomi raphael cdsp firmware"

	install -Dm644 "$builddir"/sm8150/raphael/cdsp* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}
ipa() {
	pkgdesc="Xiaomi raphael ipa firmware"

	install -Dm644 "$builddir"/sm8150/raphael/ipa* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

modem() {
	pkgdesc="Xiaomi raphael modem firmware"

	install -Dm644 "$builddir"/sm8150/raphael/modem* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}


slpi() {
	pkgdesc="Xiaomi raphael slpi firmware"

	install -Dm644 "$builddir"/sm8150/raphael/slpi* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}
touchscreen() {
	pkgdesc="Xiaomi raphael touchscreen firmware"

	install -Dm644 "$builddir"/sm8150/raphael/good* -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

venus() {
	pkgdesc="Xiaomi raphael venus firmware"

	install -Dm644 "$builddir"/sm8150/raphael/venus.mbn -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

wlan() {
	pkgdesc="Xiaomi raphael wlan firmware"

	install -Dm644 "$builddir"/sm8150/raphael/wlanmdsp.mbn -t \
		"$subpkgdir/lib/firmware/qcom/sm8150/Xiaomi/raphael/"
}

sha512sums="
6a0305e70ffb581b957e5b987048931d3900416753189e967d2f2a5a5826ab30a929ebbd6f79fb64a80c00cef5bc6583bbd1c6825044b03f5d6fc352f84e318b  89149ad98c7c8443946a518e9fb2ff2e2c83d54d.tar.gz
cbfb62e7890e87d2dd06b54edb0df90904a62d6f6e34c48a86e784a6277f5472760ac7775b2feea91abbb30ba26fd810719250618b91b23a8913a759c681d6cb  30-gpu-firmware.files"
